package com.erp.framework.types;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Random;

import com.erp.framework.SimpleConstants;
import com.erp.framework.util.CommonUtil;

public class CustomBigInteger extends BigInteger implements SimpleConstants{
    /**
     * @param val
     */
    public CustomBigInteger(String val) {
        super(val);
    }
    
    /**
     * @param val
     */
    public CustomBigInteger(int val) {
        super(String.valueOf(val));
    }
    
    /**
     * @param val
     */
    public CustomBigInteger(double val) {
        super(String.valueOf(val));
    }
    
    /**
     * @param val
     */
    public CustomBigInteger(BigDecimal val){
        super(String.valueOf(val.intValue()));
    }
    
    /**
     * @param val
     */
    public CustomBigInteger(BigInteger val){
        super(String.valueOf(val.intValue()));
    }
    
    /**
     * @param signum
     * @param magnitude
     */
    public CustomBigInteger(int signum, byte[] magnitude) {
        super(signum, magnitude);
    }
   
    /**
     * @param val
     */
    public CustomBigInteger(byte[] val) {
        super(val);
    }

    /**
     * @param val
     * @param radix
     */
    public CustomBigInteger(String val, int radix) {
        super(val, radix);
    }

    /**
     * @param bitLength
     * @param certainty
     * @param rnd
     */
    public CustomBigInteger(int bitLength, int certainty, Random rnd) {
        super(bitLength, certainty, rnd);
    }

    /**
     * @param numBits
     * @param rnd
     */
    public CustomBigInteger(int numBits, Random rnd) {
        super(numBits, rnd);
    }
    
    public static CustomBigInteger customize(String val){
        if(CommonUtil.isEmpty(val)){
            return null;
        } else {
            return new CustomBigInteger(val);
        }
    }
    
    public static CustomBigInteger customize(BigInteger val){
        if(val == null){
            return null;
        } else {
            return new CustomBigInteger(val);
        }
    }
    
    public static CustomBigInteger customize(BigDecimal val){
        if(val == null){
            return null;
        } else {
            return new CustomBigInteger(val);
        }
    }
    
    public String toString() {
        int val = this.intValue();
        return String.valueOf(val);
    }
}
